package com.fauks.se.exception;

import java.io.File;
import java.util.Objects;

public class ExceptionDemo {
    public static void main(String[] args) {
        new ExceptionDemo().readFile(null);
    }

    public void readFile(String fileName) {
        //fileName可能为null，此处如果不尽早捕获异常或导致空指针
        //尽早捕获异常以暴露正确直接的问题
        Objects.requireNonNull(fileName);
        File file = new File(fileName);
        System.out.println(file.getAbsolutePath());
    }
}
